import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.ResultSetMetaData; 

public class DBConnection
{
	private static String dbURL = "jdbc:derby:C:\\Users\\quynhtuan\\Desktop\\uniLearn\\db\\db-derby-10.4.2.0-bin\\bin\\Agile;create=true;";
	private static Connection conn = null; 
    private static Statement stmt = null;
   
    public DBConnection()
    {
    }
    
    public Connection createConnection()
	{ 
       try {
				Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance(); 
				//Get a connection           
				conn = DriverManager.getConnection(dbURL); 
				return conn;
		   } catch (Exception except)   
    		 {          
				except.printStackTrace(); 
				return null;
			 }   
	} 

	public void shutdown()
	{ 
       try { 
           if (stmt != null)  
            {
            stmt.close();  
          } 
           if (conn != null)  {
                DriverManager.getConnection(dbURL + ";shutdown=true"); 
               conn.close(); 
           }
          } catch (SQLException sqlExcept) { }   
  	}
}